package us.mooresr.aircraftscheduling.client.events;

import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.EventHandler;
import us.mooresr.aircraftscheduling.shared.model.Reservation;
import com.google.gwt.event.shared.HasHandlers;
import com.google.gwt.event.shared.HandlerRegistration;

public class ReservationCreatedEvent extends
		GwtEvent<ReservationCreatedEvent.ReservationCreatedHandler> {

	public static Type<ReservationCreatedHandler> TYPE = new Type<ReservationCreatedHandler>();
	private Reservation reservation;

	public interface ReservationCreatedHandler extends EventHandler {
		public void onReservationCreated(ReservationCreatedEvent event);
	}

	public interface ReservationCreatedHasHandlers extends HasHandlers {
		public HandlerRegistration addReservationCreatedHandler(
				ReservationCreatedHandler handler);
	}

	public ReservationCreatedEvent(Reservation reservation) {
		this.reservation = reservation;
	}

	public Reservation getReservation() {
		return reservation;
	}

	@Override
	protected void dispatch(ReservationCreatedHandler handler) {
		handler.onReservationCreated(this);
	}

	@Override
	public Type<ReservationCreatedHandler> getAssociatedType() {
		return TYPE;
	}

	public static Type<ReservationCreatedHandler> getType() {
		return TYPE;
	}

	public static void fire(HasHandlers source, Reservation reservation) {
		source.fireEvent(new ReservationCreatedEvent(reservation));
	}
}
